<template>
  <view class="cart-box" v-if="cart.length!==0">
   <my-address></my-address>
    <view class="cart-title">
      <uni-icons type="shop" size="18"></uni-icons>
      <text>购物车</text>
    </view>
   <uni-swipe-action>
     <block v-for="(item,index) in cart" :key="item.goods_id" >
       <uni-swipe-action-item :right-options="options" @click="deleteGoods(item)">
         <my-goods :item="item" :radio="true" @change-checked="changeChecked" :numBar="true" ></my-goods>
       </uni-swipe-action-item>
     </block>
   </uni-swipe-action>
   <my-settle></my-settle>
  </view>
  <view class="empty-cart" v-else>
    <image src="../../static/cart-empty.jpg" mode=""></image>
    <text>空空如也~</text>
  </view>
</template>

<script>
  import tabbarBadge from '../../mixins/tabbar-badge';
  import {mapState,mapMutations} from 'vuex'
  export default {
    mixins:[tabbarBadge],
    data() {
      return {
        options: [{
              text: '删除', // 显示的文本内容
              style: {
                backgroundColor: '#C00000' // 按钮的背景颜色
              }
            }]
      };
    },
    computed:{
      ...mapState('m_cart',['cart'])
    },
    methods:{
      ...mapMutations('m_cart',['changeCheckedStatus','deleteGoods']),
      changeChecked(e){
        this.changeCheckedStatus(e)
      }
    }
  }
</script>

<style lang="scss">
.cart-box{
  padding-bottom: 50px;
  .cart-title{
    height: 40px;
    display: flex;
    font-size: 14px;
    align-items: center;
    padding-left: 5px;
    border-bottom: 1px solid #efefef;
    text{
      margin-left: 10px;
    }
  }
}
.empty-cart{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-top: 150px;
  image{
    width: 80px;
    height: 80px;
  }
  text{
    margin-top: 20px;
  }
}
</style>
